﻿using System;
using RpcModel;
using SqlExecHelper;
using Wedonek.RpcStore.Service.Helper;
using Wedonek.RpcStore.Service.Model;

namespace Wedonek.RpcStore.Service.DAL
{
        internal class TransactionDAL : SqlBasicClass
        {
                public TransactionDAL () : base ("TransactionList", "RpcExtendService")
                {

                }

                public BasicTransaction[] QueryRoot (RootQueryParam query, IBasicPage paging, out long count)
                {
                        paging.InitOrderBy ("Id", true);
                        return base.Query<BasicTransaction> (paging.OrderBy, paging.Index, paging.Size, out count, query.ToWhere ());
                }

                public BasicTransaction[] GetTranNode (Guid rootId)
                {
                        return base.Get<BasicTransaction> (new ISqlWhere[] {
                                new SqlWhere("ParentId", System.Data.SqlDbType.UniqueIdentifier){Value=rootId}
                        });
                }

                internal BasicTransaction[] GetTranNodes (Guid[] rootId)
                {
                        return base.Get<Guid, BasicTransaction> ("ParentId", rootId);
                }

                public TransactionInfo Get (Guid id)
                {
                        return base.GetRow<Guid, TransactionInfo> ("Id", id);
                }
        }
}
